package com.lxl.commons.mapper.impl;

import com.lxl.commons.mapper.IMapper;
import com.lxl.workbench.entity.Curator;
import javax.servlet.jsp.jstl.sql.Result;
import java.util.ArrayList;
import java.util.List;

/**
 * 馆长的Result转化成List集合
 * @author 北上寻海
 */
public class CuratorMapperImpl  implements IMapper {
    @Override
    public List<Curator> mapper(Result result) {
        List<Curator> list = new ArrayList<>();
        if(result.getRowCount()!=0){

            for (int i = 0 ;i<result.getRowCount();i++){
                Curator curator = new Curator();
                curator.setId((String)result.getRowsByIndex()[i][0]);
                curator.setCuratorName((String)result.getRowsByIndex()[i][1]);
                curator.setGender((String)result.getRowsByIndex()[i][2]);
                curator.setPhone((String)result.getRowsByIndex()[i][3]);
                curator.setEmail((String)result.getRowsByIndex()[i][4]);
                curator.setUserId((String)result.getRowsByIndex()[i][5]);
                curator.setPermissions((String)result.getRowsByIndex()[i][6]);
                list.add(curator);
            }
        }else {
            list = null;
        }
        return list;
    }
}
